home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Languages / Mops 2.7 / Mops source / Toolbox classes / TEwind < prev    next >
Encoding:
Text File  |  1995-12-20  |  3.0 KB  |  130 lines  |  [TEXT/MSET]

  1. \ 03Nov95    JRF    Disable active window before alert in TESizeCheck
  2. \ 15May93    DBH    Change echovec per mrh.  Separate TEScroller and TEwind code
  3.     \ into different files.  Implement lineEnd: method in intepret:
  4. \ 14May93    DBH    Dropped new: and test: methods.
  5.     \ Added enable: and disable: methods
  6.     \ Reworked interpret: to eliminate local variables.
  7.     \ Made theTEScroller an ivar.  Lock: and unlock: buffer in interpret:
  8. \ Sept93    mrh    revised for new controls scheme.
  9.  
  10.  
  11. need TEScroller
  12. need alert
  13.  
  14.  
  15. \ we will use TEalert when the TE size gets too large
  16.  
  17. 1 alert TEalert
  18.  
  19.  
  20. : TESizeCheck  ( n -- )
  21.     32000 >            \ we actually send up an alert a bit sooner than
  22.                     \  absolutely necessary
  23.     IF
  24.         " Too much text in this window!  Delete text to continue."
  25.         " Thanks"
  26.         "  "  "  " paramText
  27.         ActW dup IF disable: [] ELSE drop THEN    \ Disable window first
  28.         900 StopAlert disp: TEalert                \ Alert w/ Stop icon
  29.         drop  quit                                \ Back to event loop
  30.     THEN  ;
  31.  
  32.  
  33. :class  TEwind  super{ window+ }
  34.  
  35.     handle    BUFFER        \ merely a place to manipulate the TEscrap handle
  36.  
  37. \ Dec95 JRF following 3 methods brought in slightly altered from supers
  38.  
  39. :m SetContViewBounds:  { \ l t r b -- }
  40.     getRect: super  -> b -> r -> t -> l
  41.     l t r 1+ b 1+  setBounds: [ get: ^contView ] drawgrow: self
  42.     moved: [ get: ^contView ]
  43.     0 0 32000 dup  put: tempRect  update: tempRect  ;m
  44.  
  45. :m ZOOM:  { part -- }
  46.     word0  ^base  whrFEv
  47.     part makeint  call TrackBox  i->l
  48.     IF    getRect: self  put: tempRect  tempRect  call EraseRect
  49.         ^base  part makeint  word0  call ZoomWindow
  50.         setcontviewbounds: self
  51.     THEN  ;m
  52.  
  53. :m GROW:        \ Handles a mouse-down in the grow box.
  54.     get: growFlg
  55.     IF    setLimits: self            \ Omit in subclasses which need
  56.                                 \  custom grow limits
  57.         0 ^base  whrFEv  addr: growrect
  58.         call GrowWindow  ?dup
  59.         IF    unpack  size: self  ( draw: self )
  60.             penIntoWind: self
  61.             setcontviewbounds: self
  62.         THEN
  63.     ELSE
  64.         ^base  call SelectWindow
  65.     THEN
  66.     update: self  ;m
  67.  
  68.  
  69. :m CUT:
  70.     get: ^contView  cut: TEscroller
  71.     get: ^contView  fixPanRect: TEscroller
  72.     get: ^contView  caretIntoView: TEscroller  ;m
  73.  
  74. :m COPY:
  75.     get: ^contView  copy: TEscroller  ;m
  76.  
  77.  
  78. :m PASTE:
  79.     global TEScrpHandle @  put: buffer  size: buffer
  80.     get: ^contView  size: TEScroller +  TESizeCheck
  81.     get: ^contView  paste: TEscroller
  82.     get: ^contView  fixPanRect: TEscroller
  83.     get: ^contView  caretIntoView: TEscroller  ;m
  84.  
  85.  
  86. :m CLEAR:
  87.     get: ^contView  clear: TEscroller
  88.     get: ^contView  fixPanRect: TEscroller
  89.     get: ^contView  caretIntoView: TEscroller  ;m
  90.  
  91.  
  92. :m key:        \ ( char -- )
  93.     noclip
  94.     CASE[ 8 ( delete )    ]=> 8  get: ^contView  key: TEscroller
  95.         DEFAULT=>        get: ^contView  size: TEscroller 1+ TESizeCheck
  96.                          get: ^contView  key: TEscroller
  97.     ]CASE
  98. ;m
  99.  
  100.  
  101. :m INSERT: { addr len -- }
  102.     get: ^contView  size: TEscroller  len +  TESizeCheck
  103.     addr len  get: ^contView  insert: TEscroller  ;m
  104.  
  105.  
  106. ;class
  107.  
  108. endload
  109.  
  110.  
  111. \ TESTING:
  112.  
  113. TEwind        TW
  114. TEscroller    S1                            \ This will be the contview of TW
  115.  
  116.    screenbits    true  setGrow: tw
  117.                 true  setZoom: tw
  118.  
  119.  
  120. : GO
  121.     s1 test: tw
  122.     eventLoop  ;
  123.     
  124.  
  125. : GORES        \ Test getting things from a resource file
  126.     256 s1 getNew: tw  ;
  127.  
  128.  : ZZ    set: fwind   close: tw  ;
  129.  
  130.